{% extends 'siteAdmin/siteAdmin.html' %}
{% block operation %}
        {% if req.path ==pageData['subdomain']|nonone +'/siteAdmin/roleAdd' %}
            <div id="box" >
        <span class="testa">Aggiungi un ruolo</span>
        <hr></hr>
        {% if pageData['role'].id %}
            <form  method="POST" action="/siteAdmin/roleAdd?update={{pageData['role'].id}}">
        {% else %}
            <form  method="POST" action="/siteAdmin/roleAdd?add">
        {% endif %}

            <div class="row thin">
            <span class="word thin">Nome:</span>
            <span class="insert thin">
            <input id="addrole" name="addrole" type="text" value ="{{pageData['role'].name|nonone}}" tabindex="3" /></span>
            </div>
            <div class="row large lineTop">
            <span class="word large">Descrizione:</span>
                <textarea id="adddescrizione" rows="5" cols="50" value ="{{pageData['role'].descrizione|nonone}}" name="adddescrizione" tabindex="7"></textarea>
            </div>
            <div class="row thin lineTop">
            <input type="submit" value="Aggiungi"  tabindex="8" />
            <input type="reset" value="Annulla" />
            </div>
        </form>
        </div>

    {% elif req.path =='/siteAdmin/roleList' %}
        <div id="box">
                <span class="testa"><h2><b>Gestione ruoli</b> (Admin, Cliente, ClientePRO e Guest non sono modificabili)</h2> </span>

                <div class="row normal">
                <a href="/siteAdmin/roleAdd?new">
                    <img src="/templates/siteAdmin/img/add.png" alt="aggiungi un ruolo" title="aggiungi un utente"/>
                </a>
                </div>
                 {%for role in pageData['roles'] %}
                <div class="row normal lineTop" >
                <span class="sec normal"><b>{{role.name}}</b></span>
                <span class="image normal"><a href="/siteAdmin/roleDel?id={{role.id}}"><img src="/templates/siteAdmin/img/trash.png" alt="elimina ruolo" title="elimina ruolo"/></a></span>
                {% if not role.active %}
                <span class="image normal">
                    <a href="/siteAdmin/roleActive?id={{role.id}}"><img src="/templates/siteAdmin/img/active_off.png" alt="attiva ruolo" title="attiva ruolo"/></a>
                </span>
                {% else %}
                <span class="image normal">
                    <a href="/siteAdmin/roleActive?id={{role.id}}"><img src="/templates/siteAdmin/img/active_on.png" alt="disattiva ruolo" title="disattiva ruolo"/></a>
                </span>
                {% endif %}
                <span class="image normal">
                    <a href="/siteAdmin/roleMod?id={{role.id}}">
                        <img src="/templates/siteAdmin/img/modifica.png" alt="modifica ruolo" title="modifica ruolo"/>
                    </a>
                </span>
                </div>
                {% endfor %}
                <div class="row lineTop normal">
                <a href="/siteAdmin/roleAdd">
                    <img src="/templates/siteAdmin/img/add.png" alt="aggiungi un ruolo" title="aggiungi un utente"/>
                </a>
                </div>
            </div>

        {% elif req.path ==pageData['subdomain']+'/siteAdmin/roleMod' %}

        <div id="box">
        <span class="testa">Modifica il ruolo <b>{{pageData['editRole'].name}}</b></span>
        <hr></hr>
        <form action="/siteAdmin/roleUpdate" method="post" >
            <div class="row thin">
            <input type="hidden" name="id" value="{{pageData['editRole'].id}}"/>
            <span class="word thin">Nome:</span>
            <span class="insert thin">
                <input id="nome" name="nome" type="text" width="80%" value="{{pageData['editRole'].name}}" tabindex="3" />
            </span>
            </div>
            <div class="row large lineTop">
                <span class="word large">Descrizione:</span>
                <span class="word large">
                    <textarea id="note" name="note" rows="5" cols="50" tabindex="7">{{pageData['editRole'].descrizione}}</textarea>
                </span>
            </div>
             <div class="row lineTop"><br />
                <input type="submit" value="Modifica" tabindex="8" onClick='return confirm("Sei sicuro di voler modificare questo ruolo?")'/>
            </div>
        </form><br />
            <span class="word">Gestione delle azioni consentite a questo ruolo :</span><br /><br />
            {% for action in pageData['actions'] %}
                {% if action.id in pageData['roleactionsID'] %}
                <span>
                    <a href="/siteAdmin/roleActionActive?id={{action.id}}&amp;roleId={{pageData['editRole'].id}}&amp;flag=0">
                        <img src="/templates/siteAdmin/img/active_on.png" alt="{{action.id}}"/>
                    </a>&nbsp;<b>{{action.denominazione_breve}}</b>&nbsp;:&nbsp;{{action.denominazione}}</span><br />
                {% else %}
                <span ><a href="/siteAdmin/roleActionActive?id={{action.id}}&amp;roleId={{pageData['editRole'].id}}&amp;flag=1">
                        <img src="/templates/siteAdmin/img/active_off.png" alt="{{action.id}}"/></a>
               &nbsp;<b>{{action.denominazione_breve}}</b>&nbsp;:&nbsp;{{action.denominazione}}</span><br />
                {% endif %}
            {% endfor %}


        </div>

        {% endif %}
{%endblock%}
